<template>
  <div class="Home">
    <div class="header">
      <div class="header-center">
        <router-link :class="[route.path.includes('idea')?'navBar_item':'navBar-item']" to="/home/idea" @click="changeLeft('/idea')">想法</router-link>
        <router-link :class="[route.path.includes('recommend')?'navBar_item':'navBar-item']" to="/home/recommend" @click="changeLeft('/recommend')">推荐</router-link>
        <router-link :class="[route.path.includes('hot')?'navBar_item':'navBar-item']" to="/home/hot" @click="changeLeft('/hot')">热榜</router-link>
      </div>
      <div class="line"></div>
      <div class="header-right">
        <i class="iconfont icon-sousuo1"></i>
        <i class="iconfont icon-xiaoxi"></i>
      </div>
    </div>
    <div class="block"></div>
    <router-view></router-view>
  </div>
  <TabBar />
</template>

<script setup>
import TabBar from '@/components/TabBar.vue'
import { ref, reactive,onMounted } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()

const obj = reactive({
  '/idea':'108px',
  '/recommend':'170px',
  '/hot':'232px',
})
const cssLeft = reactive({
  left: '170px'
})
function changeLeft(i){
  cssLeft.left = obj[i]
  console.log(i);
}

</script>

<style lang='less' scoped>
.Home {
  width: 100%;
  height: calc(100vh - 53px);
  background: linear-gradient(0deg, #F5F5F5, #fff);
}
.header{
  display: flex;
  width: 100%;
  height: 54px;
  position: fixed;
  background: #fff;
  align-items: center;
  box-sizing: border-box;
  padding-left: 25%;
  .header-center{
    flex: 2;
    display: flex;
    .navBar-item{
      flex: 1;
      font-size: 14px;
      color: #777777;
      text-align: center;
    }
    .navBar_item{
      flex: 1;
      font-size: 15px;
      color: #000;
      font-weight: bold;
      text-align: center;
    }
  }
  .line{
    position: absolute;
    top: 33px;
    left: v-bind('cssLeft.left');
    width: 35px;
    height: 4px;
    z-index: -1;
    border-radius: 1px;
    background: linear-gradient(90deg, #2970F4, #4CB2FE);
  }
  .line::after{
    content: '';
    position: absolute;
    top: 3px;
    left: 6px;
    border-bottom-left-radius: 2px;
    border-top: 4px solid #3180F6;
    border-right: 8px solid transparent;
  }
  .header-right{
    flex: 1;
    text-align: right;
    font-size: 16px;
    font-weight: bold;
    i{
      margin-right: 18px;
    }
  }
}
.block {
  height: 54px;
}
</style>